/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 * 02111-1307, USA.
 *
 * http://www.gnu.org/copyleft/gpl.html
 */
package l1j.server.server.serverpackets;

import java.util.logging.Logger;

import l1j.server.server.Opcodes;
import l1j.server.server.model.Instance.L1ItemInstance;
import l1j.server.server.model.Instance.L1PcInstance;

// Referenced classes of package l1j.server.server.serverpackets:
// ServerBasePacket, S_SendInvOnLogin

public class S_SendInvStatusUpdate extends ServerBasePacket {

	private static final String S_SEND_INV_STATUS_UPDATE = "[S] S_SendInvStatusUpdate";
	private static Logger _log = Logger.getLogger(S_SendInvOnLogin.class
			.getName());

//	public S_SendInvStatusUpdate(L1PcInstance pc, int objid) {
//		L1ItemInstance item = pc.getInventory().getItem(objid);
//		if (item == null)
//			return;
//		// jumpを見る限り、このOpcodeはアイテム名を更新させる目的だけに使用される模様（装備後やOE後専用？）
//		// 後に何かデータを続けて送っても全て無視されてしまう
//		writeC(Opcodes.S_OPCODE_CHARINVVISUALUPDATE);
//		writeD(item.get_objectId());
//		/*
//		 * int j = l1iteminstance.getItem().getType2(); int l =
//		 * l1iteminstance.getCount();
//		 */
//		writeS(item.getViewName());
//		/*
//		 * String s = l1iteminstance.getItem().get_name(); _log.finest((new
//		 * StringBuilder()).append("item type: ").append(j).append(" enchantlvl :
//		 * ").append(l1iteminstance.getEnchantLevel()).append(" nameid :
//		 * ").append(s).toString()); if(j == 0) {
//		 * if(l1iteminstance.isStackable() && l > 1) writeS((new
//		 * StringBuilder()).append(s).append("
//		 * (").append(l).append(")").toString()); else writeS((new
//		 * StringBuilder()).append(s).toString()); } else if(j == 1) {
//		 * if(l1iteminstance.get_isid() == 0) { if(l1iteminstance.isEquipped())
//		 * writeS((new
//		 * StringBuilder()).append(l1iteminstance.getItem().get_name()).append("
//		 * (").append("$9").append(")").toString()); else writeS((new
//		 * StringBuilder()).append(l1iteminstance.getItem().get_name()).toString()); }
//		 * else if(l1iteminstance.isEquipped()) {
//		 * if(l1iteminstance.getEnchantLevel() > 0) writeS((new
//		 * StringBuilder()).append("+").append(l1iteminstance.getEnchantLevel()).append("
//		 * ").append(l1iteminstance.getItem().get_name()).append("
//		 * (").append("$9").append(")").toString()); else writeS((new
//		 * StringBuilder()).append(l1iteminstance.getItem().get_name()).append("
//		 * (").append("$9").append(")").toString()); } else
//		 * if(l1iteminstance.getEnchantLevel() > 0) writeS((new
//		 * StringBuilder()).append("+").append(l1iteminstance.getEnchantLevel()).append("
//		 * ").append(l1iteminstance.getItem().get_name()).toString()); else
//		 * writeS((new
//		 * StringBuilder()).append(l1iteminstance.getItem().get_name()).toString()); }
//		 * else if(j == 2) if(l1iteminstance.get_isid() == 0) {
//		 * if(l1iteminstance.isEquipped()) writeS((new
//		 * StringBuilder()).append(l1iteminstance.getItem().get_name()).append("
//		 * (").append("$117").append(")").toString()); else writeS((new
//		 * StringBuilder()).append(l1iteminstance.getItem().get_name()).toString()); }
//		 * else if(l1iteminstance.isEquipped()) {
//		 * if(l1iteminstance.getEnchantLevel() > 0) writeS((new
//		 * StringBuilder()).append("+").append(l1iteminstance.getEnchantLevel()).append("
//		 * ").append(l1iteminstance.getItem().get_name()).append("
//		 * (").append("$117").append(")").toString()); else writeS((new
//		 * StringBuilder()).append(l1iteminstance.getItem().get_name()).append("
//		 * (").append("$117").append(")").toString()); } else
//		 * if(l1iteminstance.getEnchantLevel() > 0) writeS((new
//		 * StringBuilder()).append("+").append(l1iteminstance.getEnchantLevel()).append("
//		 * ").append(l1iteminstance.getItem().get_name()).toString()); else
//		 * writeS((new
//		 * StringBuilder()).append(l1iteminstance.getItem().get_name()).toString());
//		 */
//	}

	public S_SendInvStatusUpdate(L1PcInstance pc, L1ItemInstance item) {
		if (item == null) {
			return;
		}
		// jumpを見る限り、このOpcodeはアイテム名を更新させる目的だけに使用される模様（装備後やOE後専用？）
		// 後に何かデータを続けて送っても全て無視されてしまう
		writeC(Opcodes.S_OPCODE_CHARINVVISUALUPDATE);
		writeD(item.getId());
		/*
		 * int j = l1iteminstance.getItem().getType2(); int l =
		 * l1iteminstance.getCount();
		 */
		writeS(item.getViewName());
		/*
		 * String s = l1iteminstance.getItem().get_name(); _log.finest((new
		 * StringBuilder()).append("item type: ").append(j).append(" enchantlvl :
		 * ").append(l1iteminstance.getEnchantLevel()).append(" nameid :
		 * ").append(s).toString()); if(j == 0) {
		 * if(l1iteminstance.isStackable() && l > 1) writeS((new
		 * StringBuilder()).append(s).append("
		 * (").append(l).append(")").toString()); else writeS((new
		 * StringBuilder()).append(s).toString()); } else if(j == 1) {
		 * if(l1iteminstance.get_isid() == 0) { if(l1iteminstance.isEquipped())
		 * writeS((new
		 * StringBuilder()).append(l1iteminstance.getItem().get_name()).append("
		 * (").append("$9").append(")").toString()); else writeS((new
		 * StringBuilder()).append(l1iteminstance.getItem().get_name()).toString()); }
		 * else if(l1iteminstance.isEquipped()) {
		 * if(l1iteminstance.getEnchantLevel() > 0) writeS((new
		 * StringBuilder()).append("+").append(l1iteminstance.getEnchantLevel()).append("
		 * ").append(l1iteminstance.getItem().get_name()).append("
		 * (").append("$9").append(")").toString()); else writeS((new
		 * StringBuilder()).append(l1iteminstance.getItem().get_name()).append("
		 * (").append("$9").append(")").toString()); } else
		 * if(l1iteminstance.getEnchantLevel() > 0) writeS((new
		 * StringBuilder()).append("+").append(l1iteminstance.getEnchantLevel()).append("
		 * ").append(l1iteminstance.getItem().get_name()).toString()); else
		 * writeS((new
		 * StringBuilder()).append(l1iteminstance.getItem().get_name()).toString()); }
		 * else if(j == 2) if(l1iteminstance.get_isid() == 0) {
		 * if(l1iteminstance.isEquipped()) writeS((new
		 * StringBuilder()).append(l1iteminstance.getItem().get_name()).append("
		 * (").append("$117").append(")").toString()); else writeS((new
		 * StringBuilder()).append(l1iteminstance.getItem().get_name()).toString()); }
		 * else if(l1iteminstance.isEquipped()) {
		 * if(l1iteminstance.getEnchantLevel() > 0) writeS((new
		 * StringBuilder()).append("+").append(l1iteminstance.getEnchantLevel()).append("
		 * ").append(l1iteminstance.getItem().get_name()).append("
		 * (").append("$117").append(")").toString()); else writeS((new
		 * StringBuilder()).append(l1iteminstance.getItem().get_name()).append("
		 * (").append("$117").append(")").toString()); } else
		 * if(l1iteminstance.getEnchantLevel() > 0) writeS((new
		 * StringBuilder()).append("+").append(l1iteminstance.getEnchantLevel()).append("
		 * ").append(l1iteminstance.getItem().get_name()).toString()); else
		 * writeS((new
		 * StringBuilder()).append(l1iteminstance.getItem().get_name()).toString());
		 */
	}

	@Override
	public byte[] getContent() {
		return getBytes();
	}

	public String getType() {
		return S_SEND_INV_STATUS_UPDATE;
	}
}
